<template>
	<div class="node-wrap">
		<div class="node-wrap-box" @click="show">
			<div class="title" style="background: #ff943e;">
				<el-icon class="icon"><el-icon-user-filled /></el-icon>
				<span>{{ nodeConfig.nodeName }}</span>
				<el-icon class="close" @click.stop="delNode()"><el-icon-close /></el-icon>
			</div>
			<div class="content">
				<span v-if="toText(nodeConfig)">{{ toText(nodeConfig) }}</span>
				<span v-else class="placeholder">请选择</span>
			</div>
		</div>
		<add-node v-model="nodeConfig.childNode" :parent-data="nodeConfig"></add-node>
		<el-drawer title="审批人设置" v-model="drawer" destroy-on-close append-to-body :size="600">
			<template #header>
				<div class="node-wrap-drawer__title">
					<label @click="editTitle" v-if="!isEditTitle">{{form.nodeName}}<el-icon class="node-wrap-drawer__title-edit"><el-icon-edit /></el-icon></label>
					<el-input v-if="isEditTitle" ref="nodeTitle" v-model="form.nodeName" clearable @blur="saveTitle" @keyup.enter="saveTitle"></el-input>
				</div>
			</template>
			<el-container>
				<el-main style="padding:0 20px 20px 20px">
					<el-form label-position="top">
					<el-tabs model-value="first" @tab-click="notice">
						<el-tab-pane label="基础设置" name="first">
							<el-form-item label="审批人员">
								<el-radio-group v-model="form.setType">
									<el-radio :label="1">指定成员</el-radio>
									<el-radio :label="2">部门主管</el-radio>
									<el-radio :label="3">指定角色</el-radio>
									<el-radio :label="0">发起人</el-radio>
								</el-radio-group>
							</el-form-item>

							<el-form-item v-if="form.setType==1" label="选择成员">
								<el-button type="primary" icon="el-icon-plus" round @click="selectHandle(1, form.nodeUserList)">选择人员</el-button>
								<div class="tags-list">
									<el-tag v-for="(user, index) in form.nodeUserList" :key="user.id" closable @close="delUser(index)" style="margin-right: 5px;font-size: 14px;">{{user.name}}</el-tag>
								</div>
							</el-form-item>

							<el-form-item v-if="form.setType==2" label="指定主管">
								发起人的第<el-input-number v-model="form.examineLevel" :min="1" style="margin: 0px 5px; width: 130px"/>级主管
							</el-form-item>

							<el-form-item v-if="form.setType==3" label="选择角色">
								<el-button type="primary" icon="el-icon-plus" round @click="selectHandle(2, form.nodeRoleList)">选择角色</el-button>
								<div class="tags-list">
									<el-tag v-for="(role, index) in form.nodeRoleList" :key="role.id" type="info" closable @close="delRole(index)"  style="margin-right: 5px;font-size: 14px;">{{role.name}}</el-tag>
								</div>
							</el-form-item>

							<el-form-item v-if="form.setType==4" label="发起人自选">
								<el-radio-group v-model="form.selectMode">
									<el-radio :label="1">自选一个人</el-radio>
									<el-radio :label="2">自选多个人</el-radio>
								</el-radio-group>
							</el-form-item>

							<el-form-item v-if="form.setType==6" label="连续主管审批终点">
								<el-radio-group v-model="form.directorMode">
									<el-radio :label="0">直到最上层主管</el-radio>
									<el-radio :label="1">自定义审批终点</el-radio>
								</el-radio-group>
								<p v-if="form.directorMode==1">直到发起人的第  <el-input-number v-model="form.directorLevel" :min="1"/> 级主管</p>
							</el-form-item>

							<el-divider style="margin: 5px 0px"></el-divider>
							<el-form-item label="">
								<el-checkbox v-model="form.timeList.termAuto" label="超时自动审批"></el-checkbox>
							</el-form-item>
							<template v-if="form.timeList.termAuto">
								<el-form-item label="审批期限（为 0 则不生效）">
									<el-input-number v-model="form.timeList.term" :min="0" style="margin-right: 5px;"/>小时
								</el-form-item>
								<el-form-item label="审批期限超时后执行">
									<el-radio-group v-model="form.timeList.termMode">
										<el-radio :label="0">自动通过</el-radio>
										<el-radio :label="1">自动拒绝</el-radio>
										<el-radio :label="2">发送提醒</el-radio>
									</el-radio-group>
								</el-form-item>
								<el-form-item label="消息模板" v-show="form.timeList.termMode == 2">
									<el-select style="width: 100%" v-model="form.timeOutTemplateId" @change="changeTimeOutMsg" class="m-2" placeholder="请选择消息模板">
										<el-option
											v-for="item in messageList"
											:key="item.id"
											:label="item.templateName"
											:value="item.id"
										/>
									</el-select>
								</el-form-item>
								<el-form-item label="参数设置" v-show="form.timeList.termMode == 2">
									<jd-form-table v-model="form.timeOutTemplateParam"  :addBtn="false" placeholder="暂无数据">
										<el-table-column prop="val" label="参数名">
											<template #default="scope">
												<el-input v-model="scope.row.field" placeholder="" readonly></el-input>
											</template>
										</el-table-column>
										<el-table-column prop="open" label="表单字段" align="center">
											<template #default="scope">
												<el-select style="width: 200px" v-model="scope.row.defaultValue" placeholder="">
													<el-option
														v-for="item in msgParams"
														:key="item.value"
														:label="item.label"
														:value="item.value"
													/>
												</el-select>
											</template>
										</el-table-column>
									</jd-form-table>
								</el-form-item>
							</template>
							<el-divider style="margin: 5px 0px"></el-divider>
							<el-form-item label="多人审批时审批方式">
								<el-radio-group v-model="form.examineMode">
									<p style="width: 100%;"><el-radio :label="1">按顺序依次审批</el-radio></p>
									<p style="width: 100%;"><el-radio :label="2">会签(可同时审批，但每个人必须审批通过)</el-radio></p>
									<p style="width: 100%;"><el-radio :label="3">或签(有一人审批通过即可)</el-radio></p>
								</el-radio-group>
							</el-form-item>
							<el-form-item label="驳回设置">
								<el-select v-model="form.rejectNode"  placeholder="选择驳回节点">
									<el-option
										v-for="item in rejectNodeList"
										:key="item.value"
										:label="item.label"
										:value="item.value"
									/>
								</el-select>
							</el-form-item>
							<el-form-item label="进度设置">
								<el-select v-model="form.taskCompletion"  placeholder="选择驳回节点">
									<el-option key="1" label="10%" value="10"/>
									<el-option key="2" label="20%" value="20"/>
									<el-option key="3" label="30%" value="30"/>
									<el-option key="4" label="40%" value="40"/>
									<el-option key="5" label="50%" value="50"/>
									<el-option key="6" label="60%" value="60"/>
									<el-option key="7" label="70%" value="70"/>
									<el-option key="8" label="80%" value="80"/>
									<el-option key="9" label="90%" value="90"/>
									<el-option key="0" label="100%" value="100"/>
								</el-select>
							</el-form-item>
						</el-tab-pane>
						<el-tab-pane label="高级设置" name="second">
							<el-form-item label="按钮配置">
								<div class="button-call">
									<el-checkbox v-model="form.successBtn" label="同意"></el-checkbox>
									<el-input v-model="form.successBtnText"/>
								</div>
								<div class="button-call">
									<el-checkbox v-model="form.refuseBtn" label="驳回"></el-checkbox>
									<el-input v-model="form.refuseBtnText"/>
								</div>
								<div class="button-call">
									<el-checkbox v-model="form.referralBtn" label="转审"></el-checkbox>
									<el-input v-model="form.referralBtnText"/>
								</div>
								<div class="button-call">
									<el-checkbox v-model="form.stopBtn" label="结束"></el-checkbox>
									<el-input v-model="form.stopBtnText"/>
								</div>
								<div class="button-call">
									<el-checkbox v-model="form.printBtn" label="打印"></el-checkbox>
									<el-input v-model="form.printBtnText"/>
								</div>
							</el-form-item>
							<el-form-item label="手写签名">
								<el-switch v-model="form.sign" />
							</el-form-item>
						</el-tab-pane>
						<el-tab-pane label="表单设置" name="third">
						    <el-form-item label="填报表单">
								<el-radio-group v-model="form.formType">
									<el-radio :label="1">同步发起表单</el-radio>
									<el-radio :label="3">选择表单</el-radio>
									<el-radio :label="4">无</el-radio>
								</el-radio-group>
						    </el-form-item>
							<el-form-item label="选择节点" v-if="form.formType==2">
								<el-select v-model="form.formNodeId"   placeholder="选择表单节点" @change="changeTable">
									<el-option :key="item.id" v-for="item in nodeFormList" :label="item.formName" :value="item.id"/>
								</el-select>
							</el-form-item>
							<el-form-item label="选择表单" v-if="form.formType==3">
								<el-select v-model="form.nodeForm"  placeholder="选择填报表单用于审核时填写" @change="changeTable">
									<el-option :key="item.id" v-for="item in nodeFormList" :label="item.formName" :value="item.id"/>
								</el-select>
							</el-form-item>
							<el-form-item label="数据表单">
								<el-radio-group v-model="form.dataFormType">
									<el-radio :label="1">同步发起表单</el-radio>
									<el-radio :label="3">选择表单</el-radio>
								</el-radio-group>
							</el-form-item>
							<el-form-item label="选择表单" v-if="form.dataFormType==3">
								<el-select v-model="form.dataForm"  placeholder="选择数据表单用于展示表单数据" @change="changeTable">
									<el-option :key="item.id" v-for="item in dataFormList" :label="item.formName" :value="item.id"/>
								</el-select>
							</el-form-item>
						</el-tab-pane>
						<el-tab-pane label="节点通知" name="fifth">
							<el-form-item label="流程待办">
								<el-select style="width: 100%" v-model="form.waitMsg">
									<el-option
										v-for="item in msgConfig"
										:key="item.value"
										:label="item.label"
										:value="item.value"
									/>
								</el-select>
							</el-form-item>
							<el-form-item label="消息模板" v-if="form.waitMsg=='on'">
								<el-select style="width: 100%" v-model="form.waitMsgTemplateId" @change="changeWaitMsg" class="m-2" placeholder="请选择消息模板">
									<el-option
										v-for="item in messageList"
										:key="item.id"
										:label="item.templateName"
										:value="item.id"
									/>
								</el-select>
							</el-form-item>
							<el-form-item label="参数设置" v-if="form.waitMsg=='on'">
								<jd-form-table v-model="form.waitMsgTemplateParam"  :addBtn="false" placeholder="暂无数据">
									<el-table-column prop="val" label="参数名">
										<template #default="scope">
											<el-input v-model="scope.row.field" placeholder="" readonly></el-input>
										</template>
									</el-table-column>
									<el-table-column prop="open" label="表单字段" align="center">
										<template #default="scope">
											<el-select style="width: 200px" v-model="scope.row.defaultValue" placeholder="">
												<el-option
													v-for="item in msgParams"
													:key="item.value"
													:label="item.label"
													:value="item.value"
												/>
											</el-select>
										</template>
									</el-table-column>
								</jd-form-table>
							</el-form-item>
							<el-form-item label="节点同意">
								<el-select style="width: 100%" v-model="form.successMsg">
									<el-option
										v-for="item in msgConfig"
										:key="item.value"
										:label="item.label"
										:value="item.value"
									/>
								</el-select>
							</el-form-item>

							<el-form-item label="消息模板" v-if="form.successMsg=='on'">
								<el-select style="width: 100%" v-model="form.successTemplateId" @change="changeSuccessMsg" class="m-2" placeholder="请选择消息模板">
									<el-option
										v-for="item in messageList"
										:key="item.id"
										:label="item.templateName"
										:value="item.id"
									/>
								</el-select>
							</el-form-item>
							<el-form-item label="参数设置" v-if="form.successMsg=='on'">
								<jd-form-table v-model="form.successTemplateParam"  :addBtn="false" placeholder="暂无数据">
									<el-table-column prop="val" label="参数名">
										<template #default="scope">
											<el-input v-model="scope.row.field" placeholder="" readonly></el-input>
										</template>
									</el-table-column>
									<el-table-column prop="open" label="表单字段" align="center">
										<template #default="scope">
											<el-select style="width: 200px" v-model="scope.row.defaultValue" placeholder="">
												<el-option
													v-for="item in msgParams"
													:key="item.value"
													:label="item.label"
													:value="item.value"
												/>
											</el-select>
										</template>
									</el-table-column>
								</jd-form-table>
							</el-form-item>

							<el-form-item label="流程驳回">
								<el-select style="width: 100%" v-model="form.refuseMsg">
									<el-option
										v-for="item in msgConfig"
										:key="item.value"
										:label="item.label"
										:value="item.value"
									/>
								</el-select>
							</el-form-item>

							<el-form-item label="消息模板" v-if="form.refuseMsg=='on'">
								<el-select style="width: 100%" v-model="form.refuseMsgTemplateId" @change="changeRefuseMsg" class="m-2" placeholder="请选择消息模板">
									<el-option
										v-for="item in messageList"
										:key="item.id"
										:label="item.templateName"
										:value="item.id"
									/>
								</el-select>
							</el-form-item>
							<el-form-item label="参数设置" v-if="form.refuseMsg=='on'">
								<jd-form-table v-model="form.refuseMsgTemplateParam"  :addBtn="false" placeholder="暂无数据">
									<el-table-column prop="val" label="参数名">
										<template #default="scope">
											<el-input v-model="scope.row.field" placeholder="" readonly></el-input>
										</template>
									</el-table-column>
									<el-table-column prop="open" label="表单字段" align="center">
										<template #default="scope">
											<el-select style="width: 200px" v-model="scope.row.defaultValue" placeholder="">
												<el-option
													v-for="item in msgParams"
													:key="item.value"
													:label="item.label"
													:value="item.value"
												/>
											</el-select>
										</template>
									</el-table-column>
								</jd-form-table>
							</el-form-item>
							<el-form-item label="流程结束">
								<el-select style="width: 100%" v-model="form.endMsg">
									<el-option
										v-for="item in msgConfig"
										:key="item.value"
										:label="item.label"
										:value="item.value"
									/>
								</el-select>
							</el-form-item>

							<el-form-item label="消息模板" v-if="form.endMsg=='on'">
								<el-select style="width: 100%" v-model="form.endTemplateId" @change="changeEndMsg" class="m-2" placeholder="请选择消息模板">
									<el-option
										v-for="item in messageList"
										:key="item.id"
										:label="item.templateName"
										:value="item.id"
									/>
								</el-select>
							</el-form-item>
							<el-form-item label="参数设置" v-if="form.endMsg=='on'">
								<jd-form-table v-model="form.endMsgTemplateParam"  :addBtn="false" placeholder="暂无数据">
									<el-table-column prop="val" label="参数名">
										<template #default="scope">
											<el-input v-model="scope.row.field" placeholder="" readonly></el-input>
										</template>
									</el-table-column>
									<el-table-column prop="open" label="表单字段" align="center">
										<template #default="scope">
											<el-select style="width: 200px" v-model="scope.row.defaultValue" placeholder="">
												<el-option
													v-for="item in msgParams"
													:key="item.value"
													:label="item.label"
													:value="item.value"
												/>
											</el-select>
										</template>
									</el-table-column>
								</jd-form-table>
							</el-form-item>
						</el-tab-pane>
					</el-tabs>
					</el-form>
				</el-main>
				<el-footer>
					<el-button type="primary" @click="save">保存</el-button>
					<el-button @click="drawer=false">取消</el-button>
				</el-footer>
			</el-container>
		</el-drawer>
	</div>
</template>

<script>
	import addNode from './addNode'

	export default {
		inject: ['select','flowModelData'],
		props: {
			modelValue: { type: Object, default: () => {} },
		},
		components: {
			addNode
		},
		data() {
			return {
				nodeConfig: {},
				treeConfig: this.$store.state.workflow,
				treeData: [],
				drawer: false,
				isEditTitle: false,
				form: {},
				// 应用ID
				appId:null,
				// 驳回节点
				rejectNodeList:[
					{
						label: "根节点",
						value: "root"
					}
				],
				// 表单数据
				formOption:[{name:"字段一",read:true,write:true,required:false,type:'input',id:'11233'}],
				// 填报表单列表
				nodeFormList:[],
				// 数据表单列表
				dataFormList:[],
				// 接口列表
				interFaceList:[],
				// 消息模板列表
				messageList:[],
				// 表单参数列表
				msgParams:[
					{label:"LaunchUserName(发起人姓名)",value:"LaunchUserName",type:"system"},
					{label:"LaunchUserId(发起人ID)",value:"LaunchUserId",type:"system"},
					{label:"OperatorUserName(当前操作用户名称)",value:"OperatorUserName",type:"system"},
					{label:"OperatorUserId(当前操作用户Id)",value:"OperatorUserId",type:"system"},
				],

				// 表单参数列表
				tableParams:[
					{label:"LaunchUserName(发起人姓名)",value:"LaunchUserName",type:"system"},
					{label:"LaunchUserId(发起人ID)",value:"LaunchUserId",type:"system"},
					{label:"OperatorUserName(当前操作用户名称)",value:"OperatorUserName",type:"system"},
					{label:"OperatorUserId(当前操作用户Id)",value:"OperatorUserId",type:"system"},
				],
				// 消息配置
				msgConfig:[
					{label:"关闭",value:"off",type:"system"},
					{label:"同步开始节点",value:"sync",type:"system"},
					{label:"自定义",value:"on",type:"system"},
				],
			}
		},
		watch:{
			modelValue(){
				this.nodeConfig = this.modelValue
			}
		},
		mounted() {
			this.appId = this.$route.query.appId;
			this.nodeConfig = this.modelValue
			this.getInterFaceList();
			this.getMessageTemplateList();
		},
		methods: {
			show(){
				this.rejectNodeList = [];
				// 转换成树状结构
				this.getTreeData();
				// 获取当前节点所有父节点
				//this.getParentNodeList(this.flowModelData.nodeConfig, this.nodeConfig.id);

				console.log('this.treeData', this.treeData);

				this.getParentNodeList(this.nodeConfig.id);

				this.rejectNodeList.splice(this.rejectNodeList.length-1,1);
				this.rejectNodeList.unshift({label:'根节点',value:'root'});
				this.$nextTick(()=>{
					this.notice()
				})
				this.getNodeFormList();
				this.getDataFormList();
				this.form = {}
				this.form = JSON.parse(JSON.stringify(this.nodeConfig))
				this.drawer = true
			},
			// 根据填报表单获取填报表单选项
			async getNodeFormList() {
				let res = await this.$API.app.form.getFormByAppId.get(this.appId,1);
				if (res.code == 200){
					this.nodeFormList =res.data;
				}
			},
			// 获取消息模板
			async getMessageTemplateList() {
				let form = {}
				form.appId = this.appId;
				let res = await this.$API.system.template.getUserTemplate.get(form);
				if (res.code == 200){
					this.messageList = res.data;
				}
			},
			// 根据填报表单获取数据表单选项
			async getDataFormList() {
				let res = await this.$API.app.form.getFormByAppId.get(this.appId,2);
				if (res.code == 200){
					this.dataFormList =res.data;
				}
			},
			// 根据应用获取接口列表
			async getInterFaceList() {
				let res = await this.$API.app.interface.getDetailByAppId.get(this.appId);
				if (res.code == 200){
					this.interFaceList =res.data;
				}
			},
			// 同意事件改变
			async changeSuccessEvent(val) {
				let res = await this.$API.app.interface.getParams.get(val);
				if (res.code == 200) {
					res.data.map((item) => {
						item.defaultValue = null;
					})
					this.form.successEventParam = res.data;
				}
			},
			//拒绝事件改变
			async changeRefuseEvent(val) {
				let res = await this.$API.app.interface.getParams.get(val);
				if (res.code == 200) {
					res.data.map((item) => {
						item.defaultValue = null;
					})
					this.form.refuseEventParam = res.data;
				}
			},
			// 结束消息改变
			async changeEndMsg(val) {
				let res = await this.$API.system.template.getTemplate.get(val);
				if (res.code == 200){
					this.form.endMsgTemplateParam =JSON.parse(res.data.parameter)
				}
			},
			// 同意消息改变
			async changeSuccessMsg(val) {
				let res = await this.$API.system.template.getTemplate.get(val);
				if (res.code == 200){
					this.form.successTemplateParam =JSON.parse(res.data.parameter)
				}
			},
			// 超时消息改变
			async changeTimeOutMsg(val) {
				let res = await this.$API.system.template.getTemplate.get(val);
				if (res.code == 200){
					this.form.timeOutTemplateParam =JSON.parse(res.data.parameter)
				}
			},
			// 拒绝消息改变
			async changeRefuseMsg(val) {
				let res = await this.$API.system.template.getTemplate.get(val);
				if (res.code == 200){
					this.form.refuseMsgTemplateParam =JSON.parse(res.data.parameter)
				}
			},
			// 待办消息改变
			async changeWaitMsg(val) {
				let res = await this.$API.system.template.getTemplate.get(val);
				if (res.code == 200){
					this.form.waitMsgTemplateParam =JSON.parse(res.data.parameter)
				}
			},
			// 加载参数
		    async notice(tab,env){
					let dataForm = null;
					let nodeForm = null;
					if (this.form.dataFormType == 1 && typeof(this.treeConfig.flowData.nodeConfig) !='undefined'){
					    dataForm = this.treeConfig.flowData.nodeConfig.dataForm;
					}
					if (this.form.dataFormType == 3){
						dataForm = this.form.dataForm;
					}
					if (this.form.formType == 1 && typeof(this.treeConfig.flowData.nodeConfig) != 'undefined'){
						nodeForm = this.treeConfig.flowData.nodeConfig.nodeForm;
					}
					if (this.form.formType == 3){
						nodeForm = this.form.nodeForm;
					}
					if (dataForm != null){
						await this.pushMsgParam(dataForm)
					}
					if (nodeForm != null){
						await this.pushMsgParam(nodeForm)
					}
			},
			// 转换成树状结构
			getTreeData(){
				console.log('this.treeConfig',this.treeConfig);
				var datas = JSON.stringify(this.treeConfig);
				//console.log(datas);
                var arrMatch = null;
				var rePattern = new RegExp(
                    /"id":"(node_\d+)","parentId":"([\s\S]*?)","nodeName":"([\s\S]*?)","type":([0-9])/,
                    "gi"
                );
                while (arrMatch = rePattern.exec(datas)) {
					var nodeItem = arrMatch[0];
					var nodeId = arrMatch[1];
					var parentId =  arrMatch[2];
					var nodeName = arrMatch[3];
					var nodeType = arrMatch[4];

					if (!(/^[\u4e00-\u9fa5_a-zA-Z0-9]+$/).test(nodeName)){
						console.log('AAAAAA',nodeItem)
						var childReg = new RegExp(
							/"childNode":{"id":"(node_\d+)","parentId":"([\s\S]*?)","nodeName":"([\s\S]*?)","type":([0-9])/,
							"gi"
						);
						var childMatch = childReg.exec(nodeItem);
						//var childMatch = nodeItem.exec(/"childNode":{"id":"(node_\d+)","parentId":"([\s\S]*?)","nodeName":"([\s\S]*?)","type":([0-9])/g);
						if (childMatch != null){
							nodeId = childMatch[1];
							parentId =  childMatch[2];
							nodeName = childMatch[3];
							nodeType = childMatch[4];
						}
					}

					var nodeItem = {
						nodeId: nodeId,
						parentId: parentId,
						nodeName: nodeName,
						nodeType: nodeType,
					}
					this.treeData.push(nodeItem);
                }
			},
			// 获取驳回节点
			getParentNodeList(nodeId){
				var nodeItem = this.treeData.find(item => item.nodeId == nodeId);
				console.log('nodeId',nodeId)
				//if (nodeItem && nodeItem.parentId!='root'){
				if (nodeItem != undefined){
					console.log('nodeItem',nodeItem);
					// var auditItem = {
					// 	nodeId: nodeItem.nodeId,
					// 	nodeName: nodeItem.nodeName
					// };
					if (nodeItem.nodeType == 1){
						this.rejectNodeList.unshift({label:nodeItem.nodeName,value:nodeItem.nodeId})
					}
					this.getParentNodeList(nodeItem.parentId);
				}
			},
			// 获取当前节点的所有父级节点
			// getParentNodeList(nodeList,currentNodeId){
			// 	console.log('currentNodeId',currentNodeId)
			// 	console.log(this.treeConfig.flowData);
			// 	if (nodeList == null || nodeList.id == currentNodeId || nodeList.type == 4){
			// 		return;
			// 	}else {
			// 		if (nodeList.type != 4 && nodeList.type != 2 && nodeList.type != 5 && nodeList.type != 6 && nodeList.type != 7 && nodeList.type != 8){
			// 			this.rejectNodeList.push({label:nodeList.nodeName,value:nodeList.id})
			// 		}
			// 		this.getParentNodeList(nodeList.childNode,currentNodeId);
			// 	}
			// },
			editTitle(){
				this.isEditTitle = true
				this.$nextTick(()=>{
					this.$refs.nodeTitle.focus()
				})
			},
			saveTitle(){
				this.isEditTitle = false
			},
			save(){
				this.$emit("update:modelValue", this.form)
				this.drawer = false
			},
			delNode(){
				this.$emit("update:modelValue", this.nodeConfig.childNode)
			},
			delUser(index){
				this.form.nodeUserList.splice(index, 1)
			},
			delRole(index){
				this.form.nodeRoleList.splice(index, 1)
			},
			selectHandle(type, data){
				this.select(type, data)
			},
			// todo表单改变事件
			changeTable(){
				this.form.formOption=this.formOption;
			},
			// 添加表单参数字段
			async pushMsgParam(id) {
				let res = await this.$API.app.form.get.get(id);
				if (res.code == 200) {
					let temp = JSON.parse(res.data.formTemplate)
					for (let i = 0; i < temp.formFields.length; i++) {
						for (let j = 0; j < temp.formFields[i].fields.length; j++) {
							let field = temp.formFields[i].fields[j]
							this.msgParams.push({
								label: "(" + field.field + ")" + field.fieldName,
								value: field.field,
								type: "form"
							},)
						}
					}
				}
			},
			toText(nodeConfig){
				if(nodeConfig.setType == 1){
					if (nodeConfig.nodeUserList && nodeConfig.nodeUserList.length>0) {
						const users = nodeConfig.nodeUserList.map(item=>item.name).join("、")
						return users
					}else{
						return false
					}
				}else if (nodeConfig.setType == 2) {
					return nodeConfig.examineLevel == 1 ? '直接主管' : `发起人的第${nodeConfig.examineLevel}级主管`
				}else if (nodeConfig.setType == 3) {
					if (nodeConfig.nodeRoleList && nodeConfig.nodeRoleList.length>0) {
						const roles = nodeConfig.nodeRoleList.map(item=>item.name).join("、")
						return '角色-' + roles
					}else{
						return false
					}
				}else if (nodeConfig.setType == 4) {
					return "发起人自选"
				}else if (nodeConfig.setType == 5) {
					return "发起人自己"
				}else if (nodeConfig.setType == 7) {
					return "连续多级主管"
				}else if (nodeConfig.setType == 0) {
					return "发起人"
				}
			}
		}
	}
</script>

<style>
.button-call {
	display: flex;
	align-items: center;
	margin-bottom: 10px;
}

.button-call .el-checkbox{
	margin-right: 40px;
}
.button-call .el-input{
	width: 343px;
}
</style>
